package com.fr.chart.core.glyph;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.axis.Axis;
import com.fr.chart.axis.CategoryAxis;
import com.fr.chart.base.equals.Equals;
import com.fr.chart.math.Projection;
import com.fr.chart.shape3d.Cubic;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Line2D.Double;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

public class DateAxis3DGlyph extends DateAxisGlyph
{
  private static final long serialVersionUID = 5544350222096632005L;
  public static final String XML_TAG = "DateAxis3DGlyph";
  private Cubic cubic;

  public DateAxis3DGlyph()
  {
  }

  public DateAxis3DGlyph(CategoryAxis paramCategoryAxis)
  {
    super(paramCategoryAxis);
  }

  public DateAxis3DGlyph(CategoryAxis paramCategoryAxis, Cubic paramCubic)
  {
    super(paramCategoryAxis);
    setCubic(paramCubic);
  }

  public void draw(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    Point2D localPoint2D = getProjection().projectee(getBounds().getX(), getBounds().getY(), 0.0D);
    localGraphics2D.translate(localPoint2D.getX(), localPoint2D.getY());
    drawAxisGrid(paramGraphics);
    drawAxisLine(paramGraphics);
    drawAxisTitle(paramGraphics);
    localGraphics2D.translate(-localPoint2D.getX(), -localPoint2D.getY());
    if (this.cubic != null)
      this.cubic.draw(localGraphics2D);
  }

  protected Point2D getPoint2DForSelf(double paramDouble)
  {
    Point2D localPoint2D = getPoint2D(paramDouble);
    return getProjection().projectee(localPoint2D.getX(), localPoint2D.getY(), 0.0D);
  }

  protected Line2D[] getGridLine(double paramDouble)
  {
    Point2D localPoint2D4;
    Point2D localPoint2D5;
    Point2D localPoint2D1 = getPoint2D(paramDouble);
    Point2D localPoint2D2 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY(), 0.0D);
    Point2D localPoint2D3 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY(), -this.cubic.getDeep());
    Line2D.Double localDouble1 = new Line2D.Double(localPoint2D2, localPoint2D3);
    if (getAxis().getPosition() == 2)
    {
      localPoint2D4 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY(), -this.cubic.getDeep());
      localPoint2D5 = getProjection().projectee(localPoint2D1.getX() + getAxisGridLength(), localPoint2D1.getY(), -this.cubic.getDeep());
    }
    else if (getAxis().getPosition() == 4)
    {
      localPoint2D4 = getProjection().projectee(localPoint2D1.getX() - getAxisGridLength(), localPoint2D1.getY(), -this.cubic.getDeep());
      localPoint2D5 = getProjection().projectee(localPoint2D1.getX() - getAxisGridLength(), localPoint2D1.getY(), -this.cubic.getDeep());
    }
    else if (getAxis().getPosition() == 1)
    {
      localPoint2D4 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY() + getAxisGridLength(), -this.cubic.getDeep());
      localPoint2D5 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY(), -this.cubic.getDeep());
    }
    else
    {
      localPoint2D4 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY() - getAxisGridLength(), -this.cubic.getDeep());
      localPoint2D5 = getProjection().projectee(localPoint2D1.getX(), localPoint2D1.getY(), -this.cubic.getDeep());
    }
    Line2D.Double localDouble2 = new Line2D.Double(localPoint2D4, localPoint2D5);
    return new Line2D[] { localDouble1, localDouble2 };
  }

  public void setCubic(Cubic paramCubic)
  {
    this.cubic = paramCubic;
  }

  public Cubic getCubic()
  {
    return this.cubic;
  }

  public Projection getProjection()
  {
    return this.cubic.getProjection();
  }

  public void setProjection(Projection paramProjection)
  {
    this.cubic.setProjection(paramProjection);
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("DateAxis3DGlyph");
    super.writeXML(paramXMLPrintWriter);
    if (this.cubic != null)
      this.cubic.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("Cubic"))
        this.cubic = ((Cubic)paramXMLableReader.readXMLObject(new Cubic()));
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof DateAxis3DGlyph))
      return false;
    DateAxis3DGlyph localDateAxis3DGlyph = (DateAxis3DGlyph)paramObject;
    if (!(super.equals(localDateAxis3DGlyph)))
      return false;
    return (Equals.equals(localDateAxis3DGlyph.getCubic(), getCubic()));
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    JSONObject localJSONObject = super.toJSONObject();
    if (this.cubic != null)
      localJSONObject.put("cubic", this.cubic.toJSONObject());
    return localJSONObject;
  }

  public String getJSAxisType()
  {
    return "DateAxis3DGlyph";
  }
}